package com.vending.controller;

import com.vending.common.response.Result;
import com.vending.model.dto.LoginRequest;
import com.vending.model.dto.LoginResponse;
import com.vending.model.entity.User;
import com.vending.service.AuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "认证管理")
@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public Result<LoginResponse> login(@RequestBody LoginRequest request) {
        return Result.success(authService.login(request));
    }

    @ApiOperation("用户注册")
    @PostMapping("/register")
    public Result<User> register(@RequestBody User user) {
        return Result.success(authService.register(user));
    }
} 